﻿<UserControl x:Class="GSF.TimeSeries.Transport.UI.UserControls.HomeUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:tsf="clr-namespace:GSF.TimeSeries.UI;assembly=GSF.TimeSeries.UI.WPF"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:tsfBinding="clr-namespace:GSF.TimeSeries.UI.Binding;assembly=GSF.TimeSeries.UI"
             xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
             Background="Transparent">

    <!--d:DesignHeight="600" d:DesignWidth="850"-->
    
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/GSF.TimeSeries.UI.WPF;Component/Resources/CommonResource.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="10*"/>                
            <RowDefinition Height="13*"/>           
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="2.5*"/>
        </Grid.ColumnDefinitions>

        <GroupBox Header="Quick Links" Grid.Row="0" Grid.Column="0" >
            
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="5*"/>
                </Grid.ColumnDefinitions>         
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                                
                <Border Background="#FF66FF66" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2">
                    <TextBlock HorizontalAlignment="Center" FontWeight="Bold" TextAlignment="Center" VerticalAlignment="Center">                        
                        <TextBlock.LayoutTransform>
                            <RotateTransform Angle="-90"/>
                        </TextBlock.LayoutTransform>
                        Subscription<LineBreak/>Functions
                    </TextBlock>
                </Border>

                <Border Background="#FF9999FF" Grid.Column="0" Grid.Row="2" Grid.RowSpan="3">
                    <TextBlock HorizontalAlignment="Center" TextAlignment="Center" VerticalAlignment="Center" FontWeight="Bold">                    
                        <TextBlock.LayoutTransform>
                            <RotateTransform Angle="-90"/>
                        </TextBlock.LayoutTransform>
                        Publication<LineBreak/>Functions
                    </TextBlock>
                </Border>

                <Border Background="#FFFFFF00" Grid.Column="0" Grid.Row="5" Grid.RowSpan="2">
                    <TextBlock HorizontalAlignment="Center" TextAlignment="Center" VerticalAlignment="Center" FontWeight="Bold">                        
                        <TextBlock.LayoutTransform>
                            <RotateTransform Angle="-90"/>
                        </TextBlock.LayoutTransform>
                        Other<LineBreak/>Functions
                    </TextBlock>
                </Border>

                <Button Content="Authorization Request" Grid.Row="0" Grid.Column="1" Tag="GSF.TimeSeries.Transport.UI.UserControls.SubscriberRequestUserControl" Click="CommonClickHandler" Style="{StaticResource HomeButtonStyle}" Width="170" Height="32"/>
                <Button Content="Measurement Subscriptions" Grid.Row="1" Grid.Column="1" Tag="GSF.TimeSeries.Transport.UI.UserControls.SubscribeMeasurementUserControl" Click="CommonClickHandler" Style="{StaticResource HomeButtonStyle}" Width="170" Height="32"/>

                <Button Content="Authorize Subscribers" Grid.Row="2" Grid.Column="1" Tag="GSF.TimeSeries.Transport.UI.UserControls.SubscriberUserControl" Click="CommonClickHandler" Style="{StaticResource HomeButtonStyle}" Width="170" Height="32"/>
                <Button Content="Measurement Access" Grid.Row="3" Grid.Column="1" Tag="GSF.TimeSeries.Transport.UI.UserControls.SubscriberMeasurementUserControl" Click="CommonClickHandler" Style="{StaticResource HomeButtonStyle}" Width="170" Height="32"/>
                <Button Content="Subscription Status" Grid.Row="4" Grid.Column="1" Tag="GSF.TimeSeries.Transport.UI.UserControls.SubscriberStatusUserControl" Click="CommonClickHandler" Style="{StaticResource HomeButtonStyle}" Width="170" Height="32"/>

                <Button Content="Browse Input Devices" Grid.Row="5" Grid.Column="1" Tag="GSF.PhasorProtocols.UI.UserControls.DeviceListUserControl" Click="CommonClickHandler" Style="{StaticResource HomeButtonStyle}" Width="170" Height="32"/>
                <Button Content="Restart Service" Grid.Row="6" Grid.Column="1" Tag="Restart" x:Name="ButtonRestart" Click="CommonClickHandler" Style="{StaticResource HomeButtonStyle}" Width="170" Height="32"/>
            </Grid>
            
            
            <!--<StackPanel Orientation="Vertical">
                
                
                
                
                
                
            </StackPanel>-->
        </GroupBox>      
        
        <Grid Grid.Row="0" Grid.Column="1">
            
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <ComboBox x:Name="ComboBoxDevice" Margin="0,0,5,0" SelectionChanged="ComboBoxDevice_SelectionChanged" DisplayMemberPath="Value" Width="Auto" MinWidth="150"/>
                <ComboBox x:Name="ComboBoxMeasurement" Margin="0,0,5,0" SelectionChanged="ComboBoxMeasurement_SelectionChanged" DisplayMemberPath="PointTag" SelectedValuePath="SignalID" Width="Auto" MinWidth="150"/>
            </StackPanel>

            <d3:ChartPlotter Name="ChartPlotterDynamic" Grid.Row="1" Margin="2" Height="250" Width="585" MainHorizontalAxisVisibility="Collapsed" ></d3:ChartPlotter>

        </Grid>

        <GroupBox Header="Current Configuration" Grid.Row="1" Grid.Column="0">
            
            <Grid>
                
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="1.6*"/>
                </Grid.ColumnDefinitions>
                
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                
                <TextBlock Text="Instance Type" FontWeight="Bold"/>
                <TextBlock x:Name="TextBlockInstance" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left"/>

                <TextBlock Text="Server Time" Grid.Column="0"  Grid.Row="1" FontWeight="Bold"/>
                <TextBlock x:Name="TextBlockServerTime" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left"/>

                <TextBlock Text="Local Time" Grid.Column="0"  Grid.Row="2" FontWeight="Bold"/>
                <TextBlock x:Name="TextBlockLocalTime" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left"/>

                <TextBlock Text="Current User" Grid.Column="0"  Grid.Row="3" FontWeight="Bold"/>
                <TextBlock x:Name="TextBlockUser" Grid.Row="3" Grid.Column="1" HorizontalAlignment="Left" TextWrapping="Wrap"/>

                <TextBlock Text="Version Information"  Grid.Column="0" Grid.ColumnSpan="2"  Grid.Row="4" FontWeight="Bold" HorizontalAlignment="Left"/>

                <TextBlock Text="Server" Grid.Column="0"  Grid.Row="5" FontWeight="Bold"/>
                <TextBlock x:Name="TextBlockVersion" Grid.Row="5" Grid.Column="1" HorizontalAlignment="Left"/>

                <TextBlock Text="Manager" Grid.Column="0"  Grid.Row="6" FontWeight="Bold"/>
                <TextBlock x:Name="TextBlockManagerVersion" Grid.Row="6" Grid.Column="1" HorizontalAlignment="Left" />
                
                <TextBlock Text="Database Information" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="7" HorizontalAlignment="Left" FontWeight="Bold"/>
                <TextBlock Text="Type" Grid.Column="0" Grid.Row="8" FontWeight="Bold"/>
                <TextBlock x:Name="TextBlockDatabaseType" Grid.Column="1" Grid.Row="8" HorizontalAlignment="Left" TextWrapping="Wrap"/>
                
                <TextBlock Text="Name" Grid.Column="0" Grid.Row="9" FontWeight="Bold" />
                <TextBlock x:Name="TextBlockDatabaseName" Grid.Column="1" Grid.Row="9" HorizontalAlignment="Left" TextWrapping="Wrap"/>
                
                <Button Content="System Status" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="10" Width="160" Height="32" FontWeight="Bold" VerticalAlignment="Bottom" Click="ButtonStatus_Click"/>

            </Grid>
            
        </GroupBox>
        
        <GroupBox x:Name="GroupBoxSystemHealth" Header="System Health" Grid.Column="1" Grid.Row="1" VerticalContentAlignment="Bottom" >
            
            <StackPanel Orientation="Vertical">
                <tsf:TsfPopup x:Name="PopupStatus" Topmost="False" Placement="Center">
                    <Border CornerRadius="5" BorderThickness="2" Background="White" BorderBrush="Blue">
                        <StackPanel Orientation="Vertical">
                            <GroupBox x:Name="GroupBoxStatus" Header="Systemn Status">
                                <ScrollViewer Margin="2" Height="275"
                                              VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" VerticalContentAlignment="Top">
                                <ScrollViewer.Content>
                                    <TextBlock x:Name="TextBlockStatus" FontFamily="Courier New" FontSize="12" HorizontalAlignment="Left" TextAlignment="Left" TextWrapping="Wrap" />
                                </ScrollViewer.Content>
                               </ScrollViewer>
                            </GroupBox>
                            <Button x:Name="ButtonClose" Content="Close" HorizontalAlignment="Right" Click="ButtonClose_Click"/>
                        </StackPanel>
                    </Border>
                </tsf:TsfPopup>
                
                <TextBlock x:Name="TextBlockSystemHealth" FontFamily="Courier New" FontSize="12" HorizontalAlignment="Left" TextAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top"/>
                
            </StackPanel>
            
        </GroupBox>
        
    </Grid>
</UserControl>
